#pragma once
/************************************************************************/
/* CurveViewer:
/* this class is in responsibility of draw the curve on the control
/************************************************************************/
#define  DEF_BASE_GYRO	35
#define  DEF_BASE_ACC	2000
#define	 DEF_BASE_MAG   800
#define  DEF_BASE_EULAR	180

typedef enum
{
	RED,
	GREEN,
	BLUE,
}CLRTYPE;

class CurveViewer : public CStatic
{
	DECLARE_DYNAMIC(CurveViewer)

public:
	CurveViewer(int baseVal);
	virtual ~CurveViewer();
//////////////////////////////////////////////////////////////////////////
public: 
	void		initViewer();
	void		setStep(int step = 1);
	void		setBaseValue(int baseVal);
	void		forwardXPos();
	void		drawCurve(float dataValue, int type);
private:
	int			calcualteDrawYPos(float dataVal);
	void		drawColorLine( int nexY, CLRTYPE type );
	void		initBufferImage();
	void		resetVal();
	void		restBkground(CDC* pDC);
private:
	bool		isBufferInited;
	CBitmap		mBufferImage;
	CDC			mBufferImageDC;
	int         mBaseValue;
	int			mStep; 

	int			mCurRedYPos;
	int			mCurGreenYPos;
	int			mCurBlueYPos;
	int			mCurXPos;
	int			mWndWidth;
	int			mWndHeight;

	CPen		mRedPen;
	CPen		mGreePen;
	CPen		mBluePen;
//////////////////////////////////////////////////////////////////////////
protected:
	DECLARE_MESSAGE_MAP()
	afx_msg void OnPaint();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};


